package com.tuzhi.base.jpa.domain;


import com.tuzhi.base.jpa.enums.AndOrOperate;
import com.tuzhi.base.jpa.enums.QueryTypeEnum;
import com.tuzhi.util.ObjectTzUtil;

public class QueryStatementBO extends QueryConditionBO {

    //空就不带条件
    boolean passNull = true;

    Class valClass;

    //默认值
    Object defaultVal;

    public QueryStatementBO() {
    }

    public QueryStatementBO(String propertyName, QueryTypeEnum queryTypeEnum, AndOrOperate andOrOperate) {
        this.propertyName = propertyName;
        this.queryTypeEnum = queryTypeEnum;
        this.andOrOperate = andOrOperate;
    }

    public Object transClassVal(Object obj) {
        if (valClass != null) {
            return ObjectTzUtil.parseObj(obj + "", valClass);
        }
        return obj;
    }

    public boolean isPassNull() {
        return passNull;
    }

    public QueryStatementBO setPassNull(boolean passNull) {
        this.passNull = passNull;
        return this;
    }

    public Object getDefaultVal() {
        return defaultVal;
    }

    public QueryStatementBO setDefaultVal(Object defaultVal) {
        this.defaultVal = defaultVal;
        return this;
    }

    public Class getValClass() {
        return valClass;
    }

    public QueryStatementBO setValClass(Class valClass) {
        this.valClass = valClass;
        return this;
    }

    @Override
    public String toString() {
        return "QueryStatementBO{" +
                "passNull=" + passNull +
                ", defaultVal=" + defaultVal +
                ", propertyName='" + propertyName + '\'' +
                ", objValue=" + objValue +
                ", queryTypeEnum=" + queryTypeEnum +
                ", objList=" + objList +
                ", andOrOperate=" + andOrOperate +
                '}';
    }
}
